package com.stu.spring.context.chapter05.factorybean;

import org.springframework.beans.factory.FactoryBean;

public class BookFactoryBean implements FactoryBean<BookBean> {

	private String bookConfig;

	@Override
	public BookBean getObject() throws Exception {
		BookBean bookBean = new BookBean();
		String[] tokens = bookConfig.split(",");
		bookBean.setName(tokens[0]);
		bookBean.setPrice(Double.parseDouble(tokens[1]));
		bookBean.setVersion(tokens[2]);

		return bookBean;
	}

	@Override
	public Class<?> getObjectType() {
		return BookBean.class;
	}

	public String getBookConfig() {
		return bookConfig;
	}

	public void setBookConfig(String bookConfig) {
		this.bookConfig = bookConfig;
	}
}
